<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

// [ 应用入口文件 ]
namespace think;

// [ PHP版本检查 ]
header("Content-type: text/html; charset=utf-8");
if (version_compare(PHP_VERSION, '5.5', '<')) {
    die('PHP版本过低，最少需要PHP5.5，请升级PHP版本！');
}

// 定义应用目录
define('APP_PATH', __DIR__ . '/../application/');

// 定义资源目录
define('PUBLIC_PATH', __DIR__ . '/');

//根目录 by zhaojun
define('CMF_ROOT', __DIR__ . '/../');

//缓存目录
define('CACHE_PATH', __DIR__ . '/../runtime');

//主题目录
define('THEME_PATH',__DIR__ . '/themes/');

// 检测是否安装
/**
 * 定义标记
 */
is_file(APP_PATH . 'database.php') && is_file(APP_PATH . 'install.lock') ?  define('MODULE_MARK', 'front') : define('MODULE_MARK', 'install');

/**
 * 项目定义
 * 扩展类库目录
 */
define('BASE_PATH', substr($_SERVER['SCRIPT_NAME'], 0, -10));

//uc client root
define("UC_CLIENT_ROOT", __DIR__.'/../uc_client/');

define('C_KEY', 'aaa');

// if ($_SERVER['REQUEST_URI']==='/admin') {
// 	//重定向到后台地址
//     header("Location:/admin.php?s=/admin/login/index"); 
//     exit;
// }

if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){
	header("Access-Control-Allow-Origin: *");
	header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization, CAPTCHA");
	header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH');
	exit;
}

//print_r($_GET['m']);print_r($_GET['c']);print_r($_GET['a']);exit;

// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';

// 支持事先使用静态方法设置Request对象和Config对象

// 执行应用并响应
Container::get('app')->run()->send();

// // 读取自动生成定义文件
// $build = include __DIR__ .'/build.php';
// // 运行自动生成
// \think\Build::run($build);